草庐IT

AngularJS 表达式

全部标签

javascript - 覆盖 $location pushState 历史 AngularJS

如果我是“结果页面”的返回用户,我想查看我使用的最后一个过滤器。所以我使用ngCookies来更新页面上最后使用的搜索参数。controller('Results',['$location','$cookies',function($location,$cookies){$location.search(angular.fromJson($cookies.search));}]);//willyield:/results?param1=dude¶m2=bro但是,如果我点击“返回”,我将不会被带到我期望的最后一页。那是因为另一个状态被插入了历史但用户没有察觉到。用户登陆/res

javascript - 切换大小写字符串正则表达式和数字

有没有办法在单个Javascriptswitch语句中创建多个case?在我的代码中,我通过jQuery接收字段的值。是否有可能一种情况检查字符串正则表达式而另一种情况检查相同变量的数量?我的思路是:varfield=$(this).val();varmsg;switch(field){casefield.test('Yes'):msg="FOO\n";break;case10:msg="BAR\n";break;}虽然我在这里看到:SwitchstatementforstringmatchinginJavaScript在字符串上使用switch的方法是向switch语句发送一个“真”

javascript - AngularJS - 从代码重定向到另一个域

我设置了一个plunker来描述我的问题:Plnkr实际上我想导航到另一个域中的另一个页面(向按钮单击添加一个处理程序)。但它不起作用。提前致谢。更新window.location.href="http://google.com";正在工作,但AngularJS默认的$location.absUrl服务不工作。 最佳答案 $location服务不允许重新加载页面。TheAngularwaytoperformaredirectiontoanotherdomainistousethe$windowservice:$window.loca

Javascript URL 验证正则表达式

我有以下url验证正则表达式:/(ftp|https?)://[^"]+$/这是来自引用:RegularexpressionforURLvalidation(inJavaScript)这适用于像http://localhost:8080这样的情况,但它也验证了下面我不想要的那些。上面的正则表达式不应该传递下面的url1.http://www.example..com2.http://.com3.http://.4.http://www.example.作为正则表达式的菜鸟,请帮忙第二个问题,虽然与问题无关,但正则表达式是,当我针对正则表达式/^[a-z]+$/i验证null和undef

javascript - AngularJS 从文件夹加载 Controller

我是AngularJS的新手,对如何从结构化文件夹加载Controller和其他js有疑问?例如我有结构:app/-common-users--userController.js--userService.js-orders-app.js我应该如何从文件夹用户加载Controller和服务?还有一个小问题:方形护腕是什么意思?app.config(['someThing'],function($routeProvider) 最佳答案 您可以将代码放在您想要的位置。如果将它们放入Angular模块中,Angular会找到它。所以如果你

javascript - 单击 "Apply"按钮后应用 angularjs 过滤器

我有一个很大的数据列表(4000多个项目)。开始输入时-我的浏览器卡住(最多15秒)。所以我需要关闭自动过滤功能,并将过滤功能绑定(bind)到按钮点击。通过谷歌寻找答案没有结果。我该怎么做?请帮助我:)代码:和Controller:app.controller("smsCtrl",['$scope','smsData','createDialog','$http','$filter',function($scope,smsData,createDialog,$http,$filter){...} 最佳答案 我在帮助一位同事时遇到了

javascript - 在angularJS中使用工厂方法时未定义不是函数错误

我在寻找代码中TypeError:undefinedisnotafunction的解决方案时遇到问题。我有以下app.js:varapp=angular.module('test',['ngRoute','test.services','test.directives','test.controllers']);app.config(function($routeProvider,$httpProvider,$locationProvider){$locationProvider.html5Mode(true);$routeProvider.when('/q/:q',{template

javascript - 使用 $http 在 AngularJS 中调用 cURL

我是Angular的新手,我想在我的header中传递一个访问token,但我似乎做对了。我有一个工作正常的curl请求,我正试图让它以Angular工作:curlhttp://localhost:3000/api/v1/users-IH"Authorization:Tokenapi_key=xxxxxxxxxxxxxxxxxxxxxxxxxxxx"无法正常工作的Angular$http调用$http.get('http://localhost:3000/api/v1/users',{headers:{'api_key':'xxxxxxxxxxxxxxxxxxxxxxxxxxxx'}}

javascript - gulp main-bower-files 正则表达式过滤器不起作用

为什么第二个数组bowerFiles没有过滤成仅javascript文件。vargulp=require('gulp');varmainBowerFiles=require('main-bower-files');gulp.task('default',function(){varunfiltered=mainBowerFiles();console.log('unfilteredfiles:',unfiltered);//11FILES//varjsRegEx=/js$/i;//triedthiswaytoo...varjsRegEx=newRegExp('js$','i');var

javascript - 如何让 angularJS $watch 检测样式的变化?

我有一个包含所有样式控件的富文本框。当我在其中输入新文本时-它会保存。当我对内容(文本)以及颜色突出显示和粗体文本等样式进行任何更改时,它会保存更改的文本和样式。但是,当我只更改样式而不更改任何内容时-它不会保存这些样式更改。我正在使用$watch来比较新值和旧值。如何让它在样式更改时也能正常工作? 最佳答案 angular.module("app",[]).directive('spyStyle',[function(){return{link:function(scope,element,attrs){scope.$watch(